package cn.edu.ncu.housinghub.controller.agent;

import cn.edu.ncu.housinghub.dto.request.agent.ApplyRequest;
import cn.edu.ncu.housinghub.service.AgentAuthService;
import cn.edu.ncu.housinghub.vo.Result;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 中介资质认证
 */
@RestController
@RequestMapping("/agent/auth")
public class AgentAuthController {
    @Autowired
    private  AgentAuthService agentAuthService;
    /**
     * 提交申请
     * @param applyRequest 申请信息
     * @param token 用户token
     * @return 申请结果
     */
    @PostMapping("/apply")
    public Result apply(@Valid @RequestBody ApplyRequest applyRequest, @RequestHeader("info") String token) {
        return agentAuthService.apply(applyRequest, token);
    }

    /**
     * 获取申请结果
     * @param token 用户token
     * @return 申请结果
     */
    @GetMapping("/result")
    public Result result(@RequestHeader("info") String token) {
        return agentAuthService.findApplyResult(token);
    }
}
